package atlantik;

import java.io.PrintStream;

public class Log {

	public static void debug(String message) {
		out(System.out, "DEBUG", message);
	}

	public static void info(String message) {
		out(System.out, "INFO", message);
	}

	public static void warn(String message) {
		out(System.err, "WARN", message);
	}

	public static void error(String message) {
		out(System.err, "ERROR", message);
	}

	private static void out(PrintStream out, String level, String message) {
		out.println(level + " " + message);
	}

	public static void debug(String message, Object... args) {
		out(System.out, "DEBUG", message, args);
	}

	public static void info(String message, Object... args) {
		out(System.out, "INFO", message, args);
	}

	public static void warn(String message, Object... args) {
		out(System.err, "WARN", message, args);
	}

	public static void error(String message, Object... args) {
		out(System.err, "ERROR", message, args);
	}

	public static void exception(Exception e) {
		System.err.println(e);
		e.printStackTrace(System.err);
	}

	private static void out(PrintStream out, String level, String message,
			Object... args) {
		out.println(level + " " + String.format(message, args));
	}

}
